<?php
/**
 * View  LaFabbrica.org
 * 
 * @author     luigi.pastore (gigi@la-fabbrica.org)
 * @created    30-lug-2012
 * @package    LaFabbrica
 * @copyright  Copyright (c) 2011 Luigi Pastore
 */
?>
<link rel="stylesheet" href="/css/admin/progressbar.css" type="text/css" />
<script type="text/javascript">
    //<![CDATA[
    
    $(document).ready(function()
    {
        $('tr[class^="tourbook-step"]').click(function(){
            $(this).siblings().removeClass('focused');
            $(this).toggleClass('focused');
        })  
    });

    //]]>
</script>

<div id="content">
    <div id="summary" class="tourbook">
	<div class="head">
	    <h2>Tourbook</h2>
	</div>
	<div class="body">Qui puoi compilare e stampare il Tourbook degli eventi</div>
    </div>
    <div class="help">
	<h2>Aiuto:</h2>
	<br/>
        Qui puoi compilare e stampare il Tourbook degli eventi
    </div>  
    <form>
        <ul>
	    <li class="section"><h3></h3></li>
	    <li id="errorLi" style="<?php echo $this->errorMsg ? '' : 'display:none' ?>">
		<h3 id="errorMsgLbl">Si &egrave; verificato un problema durante l'invio del modulo.</h3>
		<p id="errorMsg">
		    <?php echo $this->errorMsg ?>
		</p>
	    </li>	
        </ul>
    </form>
    <table class="tourbook statistics">
        <tr>
            <td>Indietro</td>
                
            <td class="progress-bar">
                <?php
                if( count( $this->data['live'] ) != 0 )
                    $percentuale = ((int) $this->data['tourbook_steps_count'] / count( $this->data['live'] ) ) * 100;
                else
                    $percentuale = 0;
                
                switch(true):
                    case $percentuale == 100:
                        $style = 'success';
                    break;
                    case $percentuale > 33:
                        $style = 'attention';
                    break;
                    case $percentuale < 33:
                        $style = 'error';
                    break;
                    default:
                        $style = 'blue';
                    break;
                endswitch;
                ?>
                <div class="ui-progress-bar ui-container <?php echo $style ?>" id="progress_bar"  title="<?php echo $this->data['tourbook_steps_count'] .' step su '. count( $this->data['live'] ) ; ?> live">
                    <div class="ui-progress" style="width:<?php echo ( $percentuale == 0 ) ? '100%' : $percentuale .'%' ?>">
                    </div>
                        <span class="ui-label">
                            <b class="value"><?php echo sprintf( '%d', $percentuale ); ?>%</b>
                        </span>
                </div>
                <div class="statistisc">Inserito <strong><?php echo $this->data['tourbook_steps_count'] ?></strong> step su <strong><?php echo count( $this->data['live'] ) ; ?></strong> live</div>
            </td>
            <td>Inizia</td>
        </tr>
    </table>
    <table class="log clearfix list tourbook" id="live-list">
        <tbody id="live">
            <tr class="break">
                <td colspan="5">Elenco Live</td>
            </tr>
        <?php if( count( $this->data['live'] ) > 0 ) : ?>
            <?php 
            foreach( $this->data['live'] as $live ): 
                list( $y, $m, $d ) = explode( '-', $live['live_date'] );
            ?>
            <tr class="tourbook-step">
		<td class="date">
		    <h3>
			<b><?php echo $d ?> <?php echo $this->months[sprintf( '%01d', $m )] ?> <?php echo $y ?></b>
			<span><?php echo $this->days[date( 'N', mktime( $hour, $minute, $second, $m, $d, $y ) )] ?></span>
		    </h3>		
		</td>
		<td class="artists">
                <?php 
                $main_artists = null;
                $openingact_artists = null;
                if( count( $live['artists']['main'] ) > 0 ):
                    foreach( $live['artists']['main'] as $artist ):  
                        $main_artists .= $artist['artist_name'] .', ';
                    endforeach;
                endif; ?>
                
                <strong><?php echo substr( $main_artists, 0, -2 ) ?></strong>
                <?php 
                if( count( $live['artists']['openingact'] ) > 0 ):
                    foreach( $live['artists']['openingact'] as $artist ):  
                        $openingact_artists .= $artist['artist_name'] .', ';
                    endforeach; 
                ?>
                <br/> 
                + <span><?php echo substr( $openingact_artists, 0, -2 ) ?></span>
                <?php endif; ?>
		</td>
		<td class="location">
                    <?php echo $live['location']['location_name'] ?>, <strong><?php echo $live['location']['location_city'] ?></strong> (<?php echo $this->province[$live['location']['location_province_id']]['province_short_name'] ?>)
		</td>
		<td class="live-status">
                    <div class="live-status editable">
                        <div class="live-actions" id="<?php echo $live['live_id'] ?>">
                            <span class="<?php echo $this->live_status[$live['live_status_id']]['live_status_mark'] ?>">
                                <?php echo $this->live_status[$live['live_status_id']]['live_status_name'] ?>
                            </span>
                        </div>
                    </div>
		</td>
            <td title="Vai a tourbook" class="action">
                <a href="/admin/tourbook/compila/id/<?php echo $this->data['tourbook_id'] ?>/step/<?php echo $live['step']['step_id'] ?>">
                    <img src="/images/admin/32x32/map.png"/>
                </a>
            </td>	
	    </tr>
            <?php endforeach;
else:
    ?><tr class="result"><td colspan="5">Nessun elemento presente...</td></tr> <?php	
endif;?>
        </tbody>
    </table>
</div>